package com.huangsm.juc.forkjoin;

import javax.servlet.http.HttpServletRequest;
import java.time.Duration;
import java.time.Instant;
import java.util.Stack;
import java.util.stream.LongStream;
import java.util.stream.Stream;

public class ForkJoinTest {
    public static void main(String[] args) {
        /**
         * java并行流
         */

        Instant start = Instant.now();
        //切换成并行流
        long sum = LongStream.rangeClosed(0, 100000000L)
                .parallel()
                .reduce(0, Long::sum);
        Instant end = Instant.now();
        System.out.println(sum);
        System.out.println(Duration.between(start, end).toMillis());
    }
}
